//
//  LZMyChangeInfoViewController.m
//  laziz_Consumer
//
//  Created by ZhaoDongBo on 2016/10/28.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZMyChangeInfoViewController.h"
#import "LZMyChangePasswordView.h"
#import "LZMyChangeNickNameView.h"
#import "LZMyChangeMobileView.h"

#import "UINavigationBar+BackgroundColor.h"
#import "UIViewController+NavigationItemSetting.h"
#import "GVUserDefaults+LZProperties.h"
#import "UIView+Rotation.h"

#import "Masonry.h"
#import "AppDelegate.h"
#import "LZUserModel.h"
#import "LZUserInfoPresenter.h"
#import "LZMyPersonInfoViewController.h"
#import "LZAreaCodeViewController.h"
#import "LZRemindView.h"
#import "extobjc.h"
#import "LZAlertView.h"

@interface LZMyChangeInfoViewController ()

@property (nonatomic, strong) LZMyChangePasswordView    * setPasswordView;
@property (nonatomic, strong) LZMyChangePasswordView    * changePasswordView;
@property (nonatomic, strong) LZMyChangeMobileView      * changeMobileIDCheckView;
@property (nonatomic, strong) LZMyChangeMobileView      * changeMobileLinkNewView;

@property (strong, nonatomic) UIButton  * nav_left_back;
@property (strong, nonatomic) UIButton  * nav_right_save;

@property (nonatomic, strong) NSString  * verifiCode;    //当前验证码
@property (nonatomic, strong) NSTimer   * timer1;         //验证码倒计时
@property (nonatomic, strong) NSTimer   * timer2;         //验证码倒计时
@property (nonatomic, assign) int count1;
@property (nonatomic, assign) int count2;

@property (nonatomic, strong) LZUserInfoPresenter * userInfoPresenter;

@property (strong, nonatomic) UINavigationController *navVC;
@property (strong, nonatomic) LZAreaCodeViewController *areaCodeVC;

@end

@implementation LZMyChangeInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Do any additional setup after loading the view.
    self.view.backgroundColor = UIColorFromRGB(0xf9f7f7, 1);
    self.userInfoPresenter = [[LZUserInfoPresenter alloc] init];
    
    self.view.userInteractionEnabled = YES;
    
    if (self.type == LZ_MYCHANGEINFO_TYPE_SETPASSWORD ||
        self.type == LZ_MYCHANGEINFO_TYPE_CHANGEPASSWORD) {
        
        [self configNavigationRigihtButton];
    }
    
    [self setup];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}

- (void)dealloc {
    
    if (self.timer1) {
        [self.timer1 invalidate];
        self.timer1 = nil;
    }
    
    if (self.timer2) {
        [self.timer2 invalidate];
        self.timer2 = nil;
    }
}

- (void)setup {
    
    WS(weakSelf);
    
    if (self.type == LZ_MYCHANGEINFO_TYPE_SETPASSWORD) {
        
        self.umLogPageViewName = @"设置密码页面";
        self.title = LZLocalizedString(@"set_password", nil);
        [self.view addSubview:self.setPasswordView];
        
        [self.setPasswordView makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.leading.mas_equalTo(0);
            make.trailing.mas_equalTo(0);
            make.height.mas_equalTo(100);
        }];
    }
    else if (self.type == LZ_MYCHANGEINFO_TYPE_CHANGEPASSWORD) {
        
        self.umLogPageViewName = @"更改密码页面";
        self.title = LZLocalizedString(@"change_password", nil);
        [self.view addSubview:self.changePasswordView];
        
        [self.changePasswordView makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.leading.mas_equalTo(0);
            make.trailing.mas_equalTo(0);
            make.height.mas_equalTo(145);
        }];
    }
    else if (self.type == LZ_MYCHANGEINFO_TYPE_IDCHECK_MOBILE) {
        
        self.umLogPageViewName = @"修改手机验证页面";
        self.title = LZLocalizedString(@"change_moblie", nil);
        [self.view addSubview:self.changeMobileIDCheckView];
        
        if ([GVUserDefaults standardUserDefaults].phoneAreaCode.length > 0) {
            self.changeMobileIDCheckView.areaCodeTextField.text = [GVUserDefaults standardUserDefaults].phoneAreaCode;
        }
        
        @weakify(self);
        self.changeMobileIDCheckView.openAreaCodeVCBlock = ^(UITextField *field){
            
            @strongify(self);
            [self presentViewController:self.navVC animated:YES completion:^{
                
            }];
            self.areaCodeVC.SelectedAreaCodeBlock = ^(NSString *codeStr){
                field.text = codeStr;
            };
        };
        
        self.changeMobileIDCheckView.getVerificButtonBlock = ^(UIButton * button) {
            
            [weakSelf getOldVerifiCode];
        };
        
        self.changeMobileIDCheckView.nextStepButtonBlock = ^(UIButton * button) {
            [weakSelf nextButtonAction];
        };
        
        [self.changeMobileIDCheckView makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.leading.mas_equalTo(0);
            make.trailing.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
        }];
    }
    else if (self.type == LZ_MYCHANGEINFO_TYPE_LINKNEW_MOBILE) {
        
        self.umLogPageViewName = @"绑定新手机页面";
        self.title = LZLocalizedString(@"personal_set", nil);
        [self.view addSubview:self.changeMobileLinkNewView];
        
        @weakify(self);
        self.changeMobileLinkNewView.openAreaCodeVCBlock = ^(UITextField *field){
            
            @strongify(self);
            [self presentViewController:self.navVC animated:YES completion:^{
                
            }];
            self.areaCodeVC.SelectedAreaCodeBlock = ^(NSString *codeStr){
                field.text = codeStr;
            };
        };
        
        self.changeMobileLinkNewView.getVerificButtonBlock = ^(UIButton * button) {
            
            [weakSelf getNewVerifiCode];
        };
        
        self.changeMobileLinkNewView.nextStepButtonBlock = ^(UIButton * button) {
            [weakSelf submitButtonAction];
        };
        
        [self.changeMobileLinkNewView makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.leading.mas_equalTo(0);
            make.trailing.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
        }];
    }
}

- (void)configNavigationRigihtButton{
    self.nav_right_save = [UIButton buttonWithType:UIButtonTypeCustom];
    self.nav_right_save.frame = CGRectMake(0, 0, 40, 40);
    self.nav_right_save.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.nav_right_save setTitle:LZLocalizedString(@"save", @"") forState:UIControlStateNormal];
    [self.nav_right_save setTitleColor:UIColorFromRGB(0x666666, 1) forState:UIControlStateNormal];
    [self.nav_right_save addTarget:self action:@selector(navbarSaveButtonClickAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [self navigationItemSetting:@[self.nav_right_save] type:NAVIGATIONITEMSETTING_RIGHT];
}

#pragma mark - event

- (void)navbarSaveButtonClickAction:(UIButton*)sender {
    
    [self.view endEditing:YES];
    
    if (self.type == LZ_SETPASSWORD_TYPE_SETPASSWORD) {    //设置密码
        [self settingPassword];
    }
    else if (self.type == LZ_SETPASSWORD_TYPE_CHANGEPASSWORD) { //更改密码
        [self changePassword];
    }
}

//快捷登录设置密码
- (void)settingPassword {
    
    if (self.setPasswordView.lzOldTextField.textField.text.length <= 0) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"提示对勾"] andContent:LZLocalizedString(@"enter_password", @"")];
        return;
    } else if (self.setPasswordView.lzOldTextField.textField.text.length > 0 &&
               self.setPasswordView.lzOldTextField.textField.text.length < 6) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"提示对勾"] andContent:LZLocalizedString(@"enter_password_6_chart", @"")];
        return;
    }
    
    [self startLoadingViewForView:self.view loadingViewUserInteractionEnabled:YES];
    
    WS(weakSelf);
    [self.userInfoPresenter userInitPasswordWithPassword:self.setPasswordView.lzOldTextField.textField.text
                                            andonSuccess:^(id data) {
                                                [weakSelf stopLoadingViewForView:self.view];
                                                
                                                DLog(@"%@", data);
                                                
                                                [[GVUserDefaults standardUserDefaults] setIsSetPassword:[[[data objectForKey:@"data"] objectForKey:@"hasPassword"] boolValue]];
                                                [weakSelf.navigationController popToRootViewControllerAnimated:YES];
                                            } onFail:^(NSString *fail) {
                                                [weakSelf stopLoadingViewForView:self.view];
                                                
                                                [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                                                                 andContent:LZLocalizedString(@"save_failed", @"")];
                                                DLog(@"error: %@", fail);
                                            }];
}


- (void)changePassword {
    
    if (self.changePasswordView.lzOldTextField.textField.text.length <= 0) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                         andContent:LZLocalizedString(@"enter_old_password", @"")];
        return;
    } else if (self.changePasswordView.lzOldTextField.textField.text.length > 0 &&
               self.changePasswordView.lzOldTextField.textField.text.length < 6) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                         andContent:LZLocalizedString(@"enter_password_6_chart", @"")];
        return;
    }
    
    if (self.changePasswordView.lzNewTextField.textField.text.length <= 0) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                         andContent:LZLocalizedString(@"enter_new_password", @"")];
        return;
    } else if (self.changePasswordView.lzNewTextField.textField.text.length > 0 &&
               self.changePasswordView.lzNewTextField.textField.text.length < 6) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                         andContent:LZLocalizedString(@"enter_password_6_chart", @"")];
        return;
    }
    
    [self startLoadingViewForView:self.view loadingViewUserInteractionEnabled:YES];
    
    WS(weakSelf);
    [self.userInfoPresenter userChangePassword:self.changePasswordView.lzOldTextField.textField.text
                                andNewPassword:self.changePasswordView.lzNewTextField.textField.text andonSuccess:^(id data) {
                                    
                                    [weakSelf stopLoadingViewForView:self.view];
                                    DLog(@"更改密码:%@", data);
                                    [LZRemindView initWithImage:[UIImage imageNamed:@"提示对勾"]
                                                     andContent:LZLocalizedString(@"change_success", @"")];
                                    
                                    [weakSelf.navigationController popViewControllerAnimated:YES];
                                } onFail:^(NSString *fail) {
                                    
                                    [weakSelf stopLoadingViewForView:self.view];
                                    DLog(@"error: %@", fail);
                                    [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                                                     andContent:LZLocalizedString(@"change_failed", @"")];
                                }];
}

//获取验证码
- (void)getOldVerifiCode {
    
    if (self.changeMobileIDCheckView.mobileNumTextField.text.length <= 0) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                         andContent:LZLocalizedString(@"login_enter_mobile", @"")];
        return;
    }
    
    NSString * mobileStr = [NSString stringWithFormat:@"%@%@",
                            self.changeMobileIDCheckView.areaCodeTextField.text,
                            self.changeMobileIDCheckView.mobileNumTextField.text];
//    if (mobileStr.length < 11) {
//        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
//                         andContent:LZLocalizedString(@"enter_invalid_mobile", @"")];
//        return;
//    }
    
    //显示倒计时
    [self startTimer1];
    [self startLoadingViewForView:self.view loadingViewUserInteractionEnabled:YES];
    
    WS(weakSelf);
    //验证手机号
    [self.userInfoPresenter userValidateUserPhoneWithMoblieNum:mobileStr andonSuccess:^(id data) {
        
        [weakSelf.userInfoPresenter userGetVerificationPhoneNum:mobileStr andonSuccess:^(id data) {
            
            DLog(@"获取验证码：%@", data);
            
            [weakSelf stopLoadingViewForView:weakSelf.view];
            weakSelf.verifiCode = [NSString stringWithFormat:@"%@", [data objectForKey:@"data"]];
            
        } onFail:^(NSString *fail) {
            
            [weakSelf stopLoadingViewForView:weakSelf.view];
            [weakSelf stopTimer1];
            
            if ([fail isEqualToString:@"9999999"]) {
//                [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
//                                 andContent:LZLocalizedString(@"send_code_maxnum_remind", nil)];
                LZAlertView *alert = [[LZAlertView alloc] initWithContent:LZLocalizedString(@"send_code_maxnum_remind", nil)
                                                                 andImage:[UIImage imageNamed:@"错误提示"]
                                                        cancelButtonTitle:LZLocalizedString(@"confirm", nil)
                                                        otherButtonTitles:nil, nil];
                [alert show];
                
            }
            else {
                [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                                 andContent:LZLocalizedString(@"vificode_failed", nil)];
                
            }
            
            DLog(@"%@", fail);
        }];
        
    } onFail:^(NSString *fail) {
        
        DLog(@"%@", fail);
        
        [weakSelf stopLoadingViewForView:weakSelf.view];
        [weakSelf stopTimer1];
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                         andContent:LZLocalizedString(@"vificode_failed", nil)];
    }];
}

- (void)startTimer1 {
    self.changeMobileIDCheckView.countdownLabel.text = @"60s";
    [self.timer1 invalidate];
    self.count1 = 0;
    self.timer1 = [NSTimer scheduledTimerWithTimeInterval:1
                                                   target:self
                                                 selector:@selector(updateTimeIDCheck)
                                                 userInfo:nil
                                                  repeats:YES];
    
    self.changeMobileIDCheckView.countdownLabel.hidden = NO;
    self.changeMobileIDCheckView.verificCodeButton.hidden = YES;
}

- (void)stopTimer1 {
    [self.timer1 invalidate];
    self.changeMobileIDCheckView.countdownLabel.hidden = YES;
    self.changeMobileIDCheckView.verificCodeButton.hidden = NO;
}

- (void)updateTimeIDCheck
{
    self.count1 ++;
    if (self.count1 >= 60) {
        [self stopTimer1];
        return;
    }
    
    self.changeMobileIDCheckView.countdownLabel.text = [NSString stringWithFormat:@"%is", 60-self.count1];
    
    if (self.count1 == 60) {
        self.changeMobileIDCheckView.countdownLabel.hidden = YES;
        self.changeMobileIDCheckView.verificCodeButton.hidden = NO;
    }
}

//获取验证码
- (void)getNewVerifiCode {
    
    if (self.changeMobileLinkNewView.mobileNumTextField.text.length <= 0) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                         andContent:LZLocalizedString(@"login_enter_mobile", @"")];
        return;
    }
    
    NSString * mobileStr = [NSString stringWithFormat:@"%@%@",
                            self.changeMobileLinkNewView.areaCodeTextField.text,
                            self.changeMobileLinkNewView.mobileNumTextField.text];
//    if (mobileStr.length < 11) {
//        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
//                         andContent:LZLocalizedString(@"enter_invalid_mobile", @"")];
//        return;
//    }
    
    //显示倒计时
    [self startTimer2];
    [self startLoadingViewForView:self.view loadingViewUserInteractionEnabled:YES];
    
    WS(weakSelf);
    [self.userInfoPresenter userGetVerificationPhoneNum:mobileStr andonSuccess:^(id data) {
        
        DLog(@"获取验证码：%@", data);
        
        [weakSelf stopLoadingViewForView:weakSelf.view];
        weakSelf.verifiCode = [NSString stringWithFormat:@"%@", [data objectForKey:@"data"]];
        
    } onFail:^(NSString *fail) {
        DLog(@"%@", fail);
        
        [weakSelf stopLoadingViewForView:weakSelf.view];
        [weakSelf stopTimer2];
        
        if ([fail isEqualToString:@"9999999"]) {
//            [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
//                             andContent:LZLocalizedString(@"send_code_maxnum_remind", nil)];
            LZAlertView *alert = [[LZAlertView alloc] initWithContent:LZLocalizedString(@"send_code_maxnum_remind", nil)
                                                             andImage:[UIImage imageNamed:@"错误提示"]
                                                    cancelButtonTitle:LZLocalizedString(@"confirm", nil)
                                                    otherButtonTitles:nil, nil];
            [alert show];

        }
        else {
            [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"]
                             andContent:LZLocalizedString(@"vificode_failed", nil)];

        }
        
    }];
}

- (void)startTimer2 {
    self.changeMobileLinkNewView.countdownLabel.text = @"60s";
    [self.timer2 invalidate];
    self.count2 = 0;
    self.timer2 = [NSTimer scheduledTimerWithTimeInterval:1
                                                   target:self
                                                 selector:@selector(updateTimeLinkNew)
                                                 userInfo:nil
                                                  repeats:YES];
    
    self.changeMobileLinkNewView.countdownLabel.hidden = NO;
    self.changeMobileLinkNewView.verificCodeButton.hidden = YES;
}

- (void)stopTimer2 {
    [self.timer2 invalidate];
    self.changeMobileLinkNewView.countdownLabel.hidden = YES;
    self.changeMobileLinkNewView.verificCodeButton.hidden = NO;
}

- (void)updateTimeLinkNew
{
    self.count2 ++;
    if (self.count2 >= 60) {
        [self stopTimer2];
        return;
    }
    
    self.changeMobileLinkNewView.countdownLabel.text = [NSString stringWithFormat:@"%is", 60-self.count2];
    
    if (self.count2 == 60) {
        self.changeMobileLinkNewView.countdownLabel.hidden = YES;
        self.changeMobileLinkNewView.verificCodeButton.hidden = NO;
    }
}


#pragma mark - btn Action
- (void)nextButtonAction {
    
    if (self.verifiCode == nil) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"] andContent:LZLocalizedString(@"login_get_verifi_code", @"")];
        return;
    }
    else if (![self.changeMobileIDCheckView.verificCodeTextField.text isEqualToString:self.verifiCode]) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"] andContent:LZLocalizedString(@"enter_invalid_verifi", @"")];
        return;
    }
    
    LZMyChangeInfoViewController * vc = [[LZMyChangeInfoViewController alloc] init];
    vc.type = LZ_MYCHANGEINFO_TYPE_LINKNEW_MOBILE;
    vc.moblieNumber = [NSString stringWithFormat:@"%@%@",
                       self.changeMobileIDCheckView.areaCodeTextField.text,
                       self.changeMobileIDCheckView.mobileNumTextField.text];
    vc.oldVerifiCode = self.changeMobileIDCheckView.verificCodeTextField.text;
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)submitButtonAction {
    
    if (self.type == LZ_MYCHANGEINFO_TYPE_IDCHECK_MOBILE) {
        [self changePhoneAction];
    }else if (self.type == LZ_MYCHANGEINFO_TYPE_LINKNEW_MOBILE){
        [self bindPhoneAction];
    }
}


/**
 绑定手机
 */
- (void)bindPhoneAction
{
    if (self.verifiCode == nil) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"] andContent:LZLocalizedString(@"login_get_verifi_code", @"")];
        return;
    }
    else if (![self.changeMobileLinkNewView.verificCodeTextField.text isEqualToString:self.verifiCode]) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"] andContent:LZLocalizedString(@"enter_invalid_verifi", @"")];
        return;
    }
    
    NSString * mobileStr = [NSString stringWithFormat:@"%@%@",
                            self.changeMobileLinkNewView.areaCodeTextField.text,
                            self.changeMobileLinkNewView.mobileNumTextField.text];
    
    [self startLoadingViewForView:self.view loadingViewUserInteractionEnabled:YES];
    
    @weakify(self);
    [self.userInfoPresenter bindPhoneWithPhone:mobileStr Valicode:self.verifiCode Success:^(id data) {
        @strongify(self);
         [self stopLoadingViewForView:self.view];
        [GVUserDefaults standardUserDefaults].cellphone = mobileStr;
        [self.navigationController popViewControllerAnimated:YES];
        
    } Failure:^(NSString *fail) {
        @strongify(self);
        [self stopLoadingViewForView:self.view];
        
        if ([fail isEqualToString:@"0500016"]) {//绑定手机失败
            [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"] andContent:LZLocalizedString(@"change_failed", @"")];
        }
    }];
}


/**
 修改手机
 */
- (void)changePhoneAction
{
    if (self.verifiCode == nil) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"] andContent:LZLocalizedString(@"login_get_verifi_code", @"")];
        return;
    }
    else if (![self.changeMobileLinkNewView.verificCodeTextField.text isEqualToString:self.verifiCode]) {
        [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"] andContent:LZLocalizedString(@"enter_invalid_verifi", @"")];
        return;
    }
    
    NSString * mobileStr = [NSString stringWithFormat:@"%@%@",
                            self.changeMobileLinkNewView.areaCodeTextField.text,
                            self.changeMobileLinkNewView.mobileNumTextField.text];
    
    [self startLoadingViewForView:self.view loadingViewUserInteractionEnabled:YES];
    
    WS(weakSelf);
    [self.userInfoPresenter userChangeOldMoblieNum:self.moblieNumber
                                  andOldVerifiCode:self.oldVerifiCode
                                   andNewMoblieNum:mobileStr
                                  andNewVerifiCode:self.verifiCode
                                      andonSuccess:^(id data) {
                                          DLog(@"%@", data);
                                          
                                          NSDictionary *dic = (NSDictionary *)data;
                                          [GVUserDefaults standardUserDefaults].userToken = dic[@"data"][@"token"];
                                          [GVUserDefaults standardUserDefaults].cellphone = dic[@"data"][@"cellPhone"];
                                          
                                          [weakSelf stopLoadingViewForView:weakSelf.view];
                                          [LZRemindView initWithImage:[UIImage imageNamed:@"提示对勾"] andContent:LZLocalizedString(@"msg_change_mobile", @"")];
                                          
                                          for (UIViewController *vc in weakSelf.navigationController.viewControllers) {
                                              if ([vc isKindOfClass:[LZMyPersonInfoViewController class]]) {
                                                  [self.navigationController popToViewController:vc animated:YES];
                                                  return;
                                              }
                                          }
                                          
                                      } onFail:^(NSString *fail) {
                                          [weakSelf stopLoadingViewForView:weakSelf.view];
                                          [LZRemindView initWithImage:[UIImage imageNamed:@"错误提示"] andContent:LZLocalizedString(@"change_failed", @"")];
                                          DLog(@"%@", fail);
                                      }];

}

#pragma mark - Setter/Getter

- (LZMyChangePasswordView *)setPasswordView {
    
    if (_setPasswordView == nil) {
        _setPasswordView = [[LZMyChangePasswordView alloc] initWithType:LZ_SETPASSWORD_TYPE_SETPASSWORD];
    }
    
    return _setPasswordView;
}

- (LZMyChangePasswordView *)changePasswordView {
    
    if (_changePasswordView == nil) {
        _changePasswordView = [[LZMyChangePasswordView alloc] initWithType:LZ_SETPASSWORD_TYPE_CHANGEPASSWORD];
    }
    
    return _changePasswordView;
}

- (LZMyChangeMobileView *)changeMobileIDCheckView {
    
    if (_changeMobileIDCheckView == nil) {
        _changeMobileIDCheckView = [[LZMyChangeMobileView alloc] initWithType:LZ_CHANGEMOBLIE_TYPE_IDCHECK];
    }
    
    return _changeMobileIDCheckView;
}

- (LZMyChangeMobileView *)changeMobileLinkNewView {
    
    if (_changeMobileLinkNewView == nil) {
        _changeMobileLinkNewView = [[LZMyChangeMobileView alloc] initWithType:LZ_CHANGEMOBLIE_TYPE_LINKNEW];
    }
    
    return _changeMobileLinkNewView;
}

- (UINavigationController *)navVC
{
    if (!_navVC) {
        _navVC = [[UINavigationController alloc] initWithRootViewController:self.areaCodeVC];
        _navVC.navigationBar.translucent = NO;
        _navVC.navigationBar.barTintColor = [UIColor blackColor];
        _navVC.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:18]};
    }
    
    return _navVC;
}

- (LZAreaCodeViewController *)areaCodeVC
{
    if (!_areaCodeVC) {
        _areaCodeVC = [[LZAreaCodeViewController alloc] initWithNibName:@"LZAreaCodeViewController" bundle:nil];
    }
    
    return _areaCodeVC;
}

@end
